home *** CD-ROM | disk | FTP | other *** search
/ World of Education / World of Education.iso / world_p / pcshx10b.zip / PCSHX10B.EXE / UTILS.EXE / UTILDOCS.EXE / PDSORT.DOC < prev    next >
Text File  |  1991-10-30  |  13KB  |  295 lines

  1.                             PDSORT
  2.              A Public Domain External Sort Program
  3.  
  4. Author:   Don A. Williams
  5. Version:  3.1.0
  6. Date:     April 15, 1991
  7.  
  8.    ****************************  NOTICE!  **************************
  9.    *   Contrary to the current trend  in  MS-DOS  software  this   *
  10.    *   program,  for  whatever  it is worth,  is NOT copyrighted   *
  11.    *   (with the exception of the runtime library  from  Borland   *
  12.    *   International's  Turbo  C)!  The program,  in whole or in   *
  13.    *   part,  may be used freely in any fashion  or  environment   *
  14.    *   desired.  If  you  find this program to be useful to you,   *
  15.    *   do NOT send any contribution to the author;  in the words   *
  16.    *   of  Rick  Conn,   'Enjoy!'  However,   if  you  make  any   *
  17.    *   improvements,  I would enjoy  receiving  a  copy  of  the   *
  18.    *   modified  source.  I  can  be reached,  usually within 24   *
  19.    *   hours,  by  messages  on  any  of  the  Phoenix  systems,   *
  20.    *   particularly:                                               *
  21.    *                                                               *
  22.    *               Technoids Anonymous     [PCBOARD]               *
  23.    *                   (602) 899-4876   300/1200/2400 bps          *
  24.    *                                                               *
  25.    *   All can be reached through PC Pursuit.                      *
  26.    *                                                               *
  27.    *   or:                                                         *
  28.    *                on GEnie, mail address: DON-WILL               *
  29.    *                on CompuServ:           75410,543              *
  30.    *                                                               *
  31.    *   Every  effort has been made to avoid error and moderately   *
  32.    *   extensive testing has been  performed  on  this  program,   *
  33.    *   however, the author does not warrant it to be fit for any   *
  34.    *   purpose  or  to  be  free  from  error  and disclaims any   *
  35.    *   liability for actual or any other damage arising from the   *
  36.    *   use of this program.                                        *
  37.    *****************************************************************
  38.  
  39. PDSORT is a fully public domain external sort  program,  i.e.  it  can
  40. sort  files  that  are too big to be wholly contained in memory.  This
  41. version of PDSORT contains a fully public domain  implentation  of  an
  42. iterative version of qsort(), PDQSORT.C, that is fully compatible with
  43. the  ANSI  C  standard run time qsort().  The qsort() routine supplied
  44. with most of the C compilers is a  recursive  implementation  that  is
  45. slower  and  requires  a  great  deal  more  stack  than the iterative
  46. version.  The length of the file that  can  be  sorted  by  PDSORT  is
  47. limited  only by the available disk space,  however,  you must have at
  48. least twice as much free space as the length of the file to be  sorted
  49. -  PDSORT uses an intermediate file the size of the input file and the
  50. sorted output file will be the same size as the input file.
  51.  
  52.  
  53. USAGE:
  54.  
  55. There are three forms for executing PDSORT:
  56.  
  57.     pdsort in_file out_file [option] [max_rec_length] [key_spec ....]
  58.  
  59. and:
  60.  
  61.     pdsort - [option] [max_rec_length] [key_spec...] <in_file >out_file
  62.  
  63. and:
  64.  
  65.     pdsort <in_file >out_file
  66.  
  67. In the first form,  the input_file specification can be  any  standard
  68. MS-DOS  file  specification including full path specifications but may
  69. NOT contain "wild cards".  The output_file specification may  also  be
  70. any  standard  MS-DOS  file specification not containing "wild cards".
  71. The input_file and output_file names may be  the  same  but,  in  this
  72. case,  the input_file will be destroyed by PDSORT  by  overwriting  it
  73. with  the  input file.  If no max_record_length argument is specified,
  74. PDSORT will use a default of 256 characters/record.  No records in the
  75. input file may exceed the maximum record  length.  If  a  record  that
  76. exceeds  the  maximum  record  length  is  detected in the input file,
  77. PDSORT will issue a message identifying the record and will terminate.
  78.  
  79. In the second form, PDSORT executes as a "filter", reading and sorting
  80. standard input to produce  standard  output,  both  of  which  may  be
  81. redirected.
  82.  
  83.  
  84. In  the  third form,  PDSORT also executes as a "filter",  reading and
  85. sorting standard input to produce standard output,  both of which  may
  86. be  redirected.  The  difference between the second form and the third
  87. form is that the third form uses the default maximum  record  size  of
  88. 256 characters/record and the default sort key of the entire record.
  89.  
  90. Options:
  91.  
  92. The only options supported by version 2.1.3 of PDSORT are:
  93.  
  94.     -      A single '-',  delimited by  blanks,  instructs  PDSORT  to
  95.            operate  as a filter,  taking its input from standard input
  96.            and sending its output to standard output.
  97.  
  98.     -tpath The '-t' option allows the user to specify the path for the
  99.            intermediate file created by PDSORT.  If no  such  path  is
  100.            specified,  PDSORT  will use the path of the output file as
  101.            the path of the intermediate file.  If the "filter"  option
  102.            is selected and no intermediate file path is specified, the
  103.            intermediate file will be created in the current directory.
  104.  
  105.     -o     The  '-o'  option  will  suppress all messages except error
  106.            messages.
  107.  
  108.  
  109. Key Specification:
  110.  
  111. There  may  be  as  many keys specified as you wish.  The file will be
  112. sorted on the keys in the order in  which  they  are  specified.  Each
  113. key_spec has one of the following two formats:
  114.  
  115.     b:l:[field_options]
  116.  
  117. or:
  118.  
  119.     b-e:[field_options]
  120.  
  121. where:
  122.  
  123.     b - Specifies  the  beginning  character  position of the field in
  124.         decimal;  i.e to sort a field that is in columns 10 through 17
  125.         of the record, b would be 10.
  126.     l - Specifies the length of the field in characters; i.e to sort a
  127.         field that is in columns 10 through 17 of the record,  l would
  128.         be 8 - 10:8[:options].
  129.     e - Specifies the  ending  character  position  of  the  field  in
  130.         decimal,  inclusive;  i.e to sort a file that is in characters
  131.         10 through 17 of the record with  this  format  of  the  field
  132.         specifier would require the e be 17 - 10-17[:options].
  133.  
  134. Field Options:
  135.  
  136.     a - Specifies  that  the  sort on this field is to be in ascending
  137.         order,  the default if no field option is specified  for  this
  138.         field.
  139.  
  140.     d - Specifies  that  the sort on this field is to be in descending
  141.         order.
  142.  
  143.     c - Specifies that the sort on this field is to be case sensitive;
  144.         i.e.  the  word  Abscess"  would  sort  lower  that  the  word
  145.         "abscess".  A  case  sensitive  sort  is the default if none
  146.         is specified.
  147.  
  148.     i - Specifies  that  the  sort  on  this  field  is  to  be   case
  149.         insensitive.
  150.  
  151.     c - Specifies that this field is ASCII character data, the default
  152.         if  not  specified.  Since  PDSORT  2.0.0  supports only ASCII
  153.         character fields, this option if only for upward compatibility
  154.         with future version of PDSORT that  may  support  other  field
  155.         types such as integer (numeric).
  156.  
  157.  
  158.  
  159. Error Levels
  160.  
  161. If PDSORT terminates due to an error condition, it will set the MS-DOS
  162. ERRORLEVEL as follows:
  163.  
  164.      1·-·Invalid command argument or option.
  165.      2·-·Unable  to open the specified input file.  Possibly incorrect
  166.          file name.
  167.      3·-·Input/Output error on input file.
  168.      4·-·A record in the input file exceeds the maximum length
  169.      5·-·Insufficient space on output disk.
  170.      6·-·Insufficient space on intermediate disk.
  171.      7·-·Unable to create output file.
  172.      8·-·Input/Output error on output file.
  173.      9·-·Unable to create intermediate file.
  174.     10·-·Input/Output error on intermediate file.
  175.     11·-·Reopen failure!
  176.     12·-·Insufficient memory.
  177.  
  178. On normal termination, the ERRORLEVEL will be set to 0.
  179.  
  180.  
  181.  
  182. Examples:
  183.  
  184. Assume  a  file,  named  FILELIST,  that contains a list of file name,
  185. sizes, date/times, and paths, such as can be created by NUFIND:
  186.  
  187.     a----w           27,974 90-04-30  6:30 c:\acelst.430
  188.     a----w           28,196 90-05-21  5:05 c:\acelst.521
  189.     a----w           28,238 90-05-25  5:41 c:\acelst.525
  190.     a----w           26,705 90-05-25  5:39 c:\acelst.lst
  191.     a----w          128,537 90-05-25  5:41 c:\acelst.zip
  192.     a----w              904 90-05-23  4:33 c:\autoexec.bat
  193.     a----w           35,840 89-06-30 12:16 c:\command.com
  194.     a----w               46 89-08-20  3:53 c:\config.cal
  195.     a----w              284 90-05-21 19:52 c:\config.sys
  196.     a----w            2,128 90-05-23  4:32 c:\configur.dat
  197.     ------           39,385 89-07-14 12:00 c:\drbdos.sys
  198.     ------           18,304 89-06-30 12:16 c:\drbios.sys
  199.     ---sh-            4,096 90-03-18 13:22 c:\drildr.sys
  200.     a----w              167 89-10-11  7:56 c:\dsas.cmd
  201.     a----w              102 86-11-04  9:14 c:\ed.def
  202.     a----w           50,326 86-10-02 21:34 c:\ed.hlp
  203.     a----w            3,362 86-06-09 13:10 c:\fakey.com
  204.     a----w                0 90-05-23  7:54 c:\ftf.dat
  205.     a----w           12,275 85-06-16 18:12 c:\helpe.def
  206.     a----w               79 89-05-17  5:02 c:\indent.pro
  207.     a----w            7,122 90-01-15  1:00 c:\lineend.com
  208.     a----w            1,060 90-05-25  9:40 c:\mark0
  209.     a--sh-               41 90-05-25  9:40 c:\mirorsav.fil
  210.     a-----           41,472 90-05-25  9:40 c:\mirror.fil
  211.     a----w              237 90-02-06  5:09 c:\model
  212.     a----w           12,432 87-03-10 13:34 c:\mouse.sys
  213.     a----w              251 87-07-16 18:06 c:\newkbios.com
  214.     a----w            6,094 89-11-21 15:03 c:\no101.com
  215.     a----w            2,836 90-05-03  7:21 c:\phone.dir
  216.     a----w            2,670 89-12-01 17:00 c:\phones
  217.     a----w            2,010 90-03-18 11:14 c:\pushdir.stk
  218.     a----w           53,632 85-05-03 14:09 c:\sk.hlp
  219.     a----w           33,611 86-12-05  9:21 c:\skn.com
  220.     a----w           18,825 90-01-15  1:00 c:\synonym.com
  221.     a----w            1,610 90-05-13 16:15 c:\synonym.def
  222.     a----w           14,426 90-05-19 17:38 c:\utils
  223.     a----w            1,060 90-05-25 12:17 c:\mark1
  224.  
  225. The file path name begins in column 40 and  extends  through  80,  the
  226. file size is in columns 15 through 23,  inclusive, the file date is in
  227. columns 25 through 32,  inclusive,  and the file time is in columns 34
  228. through 39, inclusive.
  229.  
  230. A PDSORT command to sort this list so that the largest files are first
  231. and files of equal size are in name order would require the  following
  232. command:
  233.  
  234.     pdsort filelist fileout 80 15-23:d 44-80
  235.  
  236. giving the following list in the file FILEOUT:
  237.  
  238.     a----w          128,537 90-05-25  5:41 c:\acelst.zip
  239.     a----w           50,326 86-10-02 21:34 c:\ed.hlp
  240.     a-----           41,472 90-05-25  9:40 c:\mirror.fil
  241.     ------           39,385 89-07-14 12:00 c:\drbdos.sys
  242.     a----w           35,840 89-06-30 12:16 c:\command.com
  243.     a----w           28,238 90-05-25  5:41 c:\acelst.525
  244.     a----w           28,196 90-05-21  5:05 c:\acelst.521
  245.     a----w           27,974 90-04-30  6:30 c:\acelst.430
  246.     a----w           26,705 90-05-25  5:39 c:\acelst.lst
  247.     a----w           18,825 90-01-15  1:00 c:\synonym.com
  248.     ------           18,304 89-06-30 12:16 c:\drbios.sys
  249.     a----w           14,426 90-05-19 17:38 c:\utils
  250.     a----w           12,432 87-03-10 13:34 c:\mouse.sys
  251.     a----w           12,275 85-06-16 18:12 c:\helpe.def
  252.     a----w            7,122 90-01-15  1:00 c:\lineend.com
  253.     a----w            6,094 89-11-21 15:03 c:\no101.com
  254.     ---sh-            4,096 90-03-18 13:22 c:\drildr.sys
  255.     a----w            3,362 86-06-09 13:10 c:\fakey.com
  256.     a----w            2,836 90-05-03  7:21 c:\phone.dir
  257.     a----w            2,670 89-12-01 17:00 c:\phones
  258.     a----w            2,128 90-05-23  4:32 c:\configur.dat
  259.     a----w            2,010 90-03-18 11:14 c:\pushdir.stk
  260.     a----w            1,610 90-05-13 16:15 c:\synonym.def
  261.     a----w            1,060 90-05-25  9:40 c:\mark0
  262.     a----w            1,060 90-05-25 12:17 c:\mark1
  263.     a----w              904 90-05-23  4:33 c:\autoexec.bat
  264.     a----w              284 90-05-21 19:52 c:\config.sys
  265.     a----w              251 87-07-16 18:06 c:\newkbios.com
  266.     a----w              237 90-02-06  5:09 c:\model
  267.     a----w              167 89-10-11  7:56 c:\dsas.cmd
  268.     a----w              102 86-11-04  9:14 c:\ed.def
  269.     a----w               79 89-05-17  5:02 c:\indent.pro
  270.     a----w               46 89-08-20  3:53 c:\config.cal
  271.     a--sh-               41 90-05-25  9:40 c:\mirorsav.fil
  272.     a----w                0 90-05-23  7:54 c:\ftf.dat
  273.  
  274. The same sort could be accomplished by the command:
  275.  
  276.     pdsort - 80 15-23:d 40-80 <filelist >fileout
  277.  
  278.  
  279. Now suppose that you wanted the most recently modified or  created  files
  280. first.  The following command would do that:
  281.  
  282.     pdsort filelist fileout 80 25-32:d 34-39:d 40-80
  283.  
  284. giving the following list in FILEOUT:
  285.  
  286.     a----w            1,060 90-05-25 12:17 c:\mark1
  287.     a----w            1,060 90-05-25  9:40 c:\mark0
  288.   ...etc.
  289.  
  290. Again,  the same sort could have been accomplished  by  the  following
  291. command:
  292.  
  293.     pdsort - 25-32:d 34-39:d 40-80 <filelist >fileout
  294.  
  295.